package com.mcptt.config.user.profile.sub.sub.sub;

import java.util.List;

import org.jdom.Element;
import org.jdom.JDOMException;

import com.cloudptt.api.product.log.Log;

public class PrivateCallURI
{
	public static final String Name = "PrivateCallURI";
	private static final String Name_UriEntry = "uri-entry";
	private static final String Name_DisplayName = "display-name";

	private String uriEntry = "";
	private String displayName = "";

	public void parse(Element elem) throws JDOMException
	{
		if(elem == null)
		{
			return;
		}
		List<Element> list = elem.getChildren();//��ø��ڵ���ӽڵ�  
		for(Element subElem:list) 
		{
			String name = subElem.getName();
			Log.debug(this.getClass(), "name = " + name);
			if(name == null
					|| name.length() <= 0)
			{
				return;
			}
			if(name.equals(Name_UriEntry))
			{
				uriEntry = subElem.getText();
			}
			else if(name.equals(Name_DisplayName))
			{
				displayName = subElem.getText();
			}
		}  
	}
	
	public String getUriEntry()
	{
	    return uriEntry;
	}

	public String getDisplayName()
	{
	    return displayName;
	}
	
	public String toString()
	{
		StringBuffer strBuf = new StringBuffer("\r\n");
		strBuf.append("<").append(Name).append(">").append("\r\n");

		strBuf.append("    ").append("<").append(Name_UriEntry).append(">");
		strBuf.append(uriEntry);
		strBuf.append("</").append(Name_UriEntry).append(">").append("\r\n");

		if(displayName != null
				&& displayName.length() > 0)
		{
			strBuf.append("    ").append("<").append(Name_DisplayName).append(">");
			strBuf.append(displayName);
			strBuf.append("</").append(Name_DisplayName).append(">").append("\r\n");
		}

		strBuf.append("</").append(Name).append(">");

		return strBuf.toString();
	}
}
